home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 1 / csmp-v1-150.txt < prev    next >
Encoding:
Text File  |  1992-12-31  |  43.5 KB  |  1,148 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Sun, 02 Aug 92       Volume 1 : Issue 150
  2.  
  3. Today's Topics:
  4.  
  5.     Emulating TrueType
  6.     Sending Apple events to the Finder.
  7.     Light-weight processes in a Mac program
  8.     need help writing a screensaver
  9.     Offscreen PixMaps
  10.     Apple Event problem
  11.     Getting the text from a TERec
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  (This means you can't post questions to the
  22. digest.)
  23.  
  24. Each issue of the digest contains one or more sets of articles (called
  25. threads), with each set corresponding to a 'discussion' of a particular
  26. subject.  The articles are not edited; all articles included in this digest
  27. are in their original posted form (as received by our news server at
  28. cs.uoregon.edu).  Article threads are not added to the digest until the last
  29. article added to the thread is at least one month old (this is to ensure that
  30. the thread is dead before adding it to the digest).  Article threads that
  31. consist of only one message are generally not included in the digest.
  32.  
  33. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  34. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  35. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  36. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  37. has a mail server; send a message with the text '$MACarch help' (no quotes)
  38. to LISTSERV@ricevm1.rice.edu for more information.
  39.  
  40. The digest is also available via email.  Just send a note saying that you
  41. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  42. automatically receive each new issue as it is created.  Sorry, back issues
  43. are not available through the mailing list.
  44.  
  45. Send administrative mail to mkelly@cs.uoregon.edu.
  46.  
  47.  
  48. -------------------------------------------------------
  49.  
  50. From: oster@well.sf.ca.us (David Phillip Oster)
  51. Subject: Emulating TrueType
  52. Organization: Whole Earth 'Lectronic Link
  53. Date: Wed, 10 Jun 1992 06:59:32 GMT
  54.  
  55. I've got the code from "develop" magazine issue 9, for extracting the bezier
  56. curves from a truetype font and drawing them on the screen, or in a PICT with
  57. the accompanying postscript. What I want to know is How does true type know
  58. how to fill the outlines. For example, you have to two concentric circles
  59. that are the curves that define a letter "o". How does TrueType know to
  60. fill the outer circle, but not fill the inner one. This is probably covered
  61. in detail in the APDA document that details the TrueType font format, but I'd
  62. like an answer sooner than that document will reach me. I want to extrude the
  63. letters into 3-d, then make them "dance" in 3-space.
  64.  
  65. +++++++++++++++++++++++++++
  66.  
  67. From: oster@well.sf.ca.us (David Phillip Oster)
  68. Organization: Whole Earth 'Lectronic Link
  69. Date: Sat, 13 Jun 1992 03:51:21 GMT
  70.  
  71. The following people responded to my question about deriving surfaces
  72. from True Type spline definitions:  
  73. TMAEHL@VAX1.UMKC.EDU    (Jonathan)
  74. lsr@taligent.com        (Larry Rosenstein) 
  75. dowdy@apple.com (Tom Dowdy)
  76. absurd@applelink.apple.com      (Tim Dierks, software saboteur (MacDTS))
  77.  
  78. all but Tom  referred me to the "winding" rasterizing algorithm in the
  79. Adobe Postscript red book. This is an algorithm for determining what
  80. pixels to turn on in a raster, essentially doing a flood fill or a
  81. paint pot of the splines. Unfortunately, I need somethng like a minimal
  82. mesh of triangles in three space, so the rasterization algorithm is
  83. just about useless. Considering each scan line as a rectangle 1 pixel
  84. tall would sort of work, but it would be hopelessly inefficient, and
  85. wouldn't take advantage of the original spline data as the viewpoint
  86. moved closer and further away from the plane of the letter.
  87.  
  88. Also, all of the people who wrote me assumed that the outsides of
  89. letters were drawn clockwise, and the outlines of interior "holes" were
  90. drawn counterclockwise. Tim, who should know, assured me that this was
  91. the case.
  92.  
  93. Watching the "Curves in QuickDraw" program draw, I am not sure that
  94. this is the case. (All though it is pretty easy to fix this, using the
  95. intersections of bound boxes to drive a heuristic.) It is certainly the
  96. case that sometimes the holes are drawn before the outsides.
  97.  
  98. If you are interested, here is Jonathon's description of the
  99. rasterization process:
  100.  
  101.  
  102. >Pure conjecture on my part, but PostScript determines what regions to
  103. >fill by crossing windings, and since TrueType is just an enhancement to
  104. >PS I'd assume it works the same way. To determine windings, draw an
  105. >imaginary line across your object at any point, and increment the wind
  106. >count when you cross a line drawn clockwise, and decrement your count
  107. >when the line is draw counterclockwise. A positive wind count  means
  108. >you are in a fill region. That is, if the outer circle is drawn
  109. >clockwise and the inner circle is drawn counterclockwise, than a
  110. >horizontal line across the 'o' would start with zero windings, cross
  111. >the first line and have one windings (so now we're filling) cross the
  112. >second line (so now we're through filling) cross the second line again
  113. >(so we're filling once more) and finally cross the first line a second
  114. >time (and we're back to our original fill status). [0 1 0 1 0] Note
  115. >that it is the change in the direction of the line crossed that is
  116. >important. That is, if the inner circle was drawn clockwise as well,
  117. >the total "winding" value would still be positive when you crossed the
  118. >second line [0 1 2 1 0] and you'd end up with a filled circle instead
  119. >of an 'o'. Or if the outer circle was wound in the opposite direction,
  120. >you would go [0 -1 -2 -1 0] and you would end up with two concentric
  121. >circles instead of an 'o' (since you are never positive and hence never
  122. >fill.)  Pick up an introductory postscript book (the adobe 'cookbooks'
  123. >are excellent) for better explanations. (or browse through the stuff
  124. >thats available for ftp on adboe.com)
  125.  
  126. Actually I'm trying to use a library that uses NURBS to describe
  127. surfaces and lets you pass it further NURBS curves to defines holes
  128. punched in the surfaces. Anybody got a good intro reference to NURBS?
  129.  
  130. I sort of know what I'm doing on this score. I wrote an article some
  131. years ago for MacTutor on how to draw the famous "teapot" on the mac
  132. using Graf3d.  It is composed of the 3-D analog of the quadratic planar
  133. bezier splines that make up true type characters. You haven't read it
  134. because MacTutor lost it before accepting it and I never got around to
  135. resubmitting it. Since I got tired of people distributing my trivial
  136. demo programs without the accompanying source code that was the
  137. _raison_d'etre_, I added a "Decompile" command to the menu which faked
  138. the THINK C "compiling' dialog running backwards, and created a mess of
  139. source files in the current directory, and also a THINK C version of
  140. the Graf3D library.
  141.  
  142. The current issue of the "born-again" MacTutor has some useful demo
  143. programs for 3-D animation, and an advertorial for a 3-D shaded surface
  144. package for $250.00 (source included.)
  145.  
  146. If anyone wants a copy of the 3-D teapot source code and article, mail
  147. $15.00 to 
  148. Mosaic Codes 
  149. Suite 2036 
  150. 2140 Shattuck Ave 
  151. Berkeley, CA 94704
  152. with a note saying "I want Teapot" and I'll send yoy a Mac floppy of
  153. the whole thing.
  154.  
  155. +++++++++++++++++++++++++++
  156.  
  157. From: parent@apple.com (Sean Parent)
  158. Date: 25 Jun 92 16:59:05 GMT
  159. Organization: Apple Computer, Inc.
  160.  
  161. In article <1992Jun13.035121.9411@well.sf.ca.us> oster@well.sf.ca.us 
  162. (David Phillip Oster) writes:
  163. > If you are interested, here is Jonathon's description of the
  164. > rasterization process:
  165. > >Pure conjecture on my part, but PostScript determines what regions to
  166. > >fill by crossing windings, and since TrueType is just an enhancement to
  167. > >PS I'd assume it works the same way.
  168.  
  169. TrueType is not "just an enhancement to PS." It is a VERY different 
  170. mechanism for rendering fonts. By convension TrueType fonts are drawn so 
  171. that they can be filled using a winding number algorithm as described but 
  172. the TrueType engine uses an xor algorithm when it fills. This is a simpler 
  173. algorithm where the state of the fill toggles as you cross an edge.
  174.  
  175. - ----------------------------------------------------------------------
  176. Sean Parent
  177. "Quality unattainable in a reasonable amount of time."
  178.  
  179. ---------------------------
  180.  
  181. From: molla@paone.uucp (Levent Mollamustafaoglu)
  182. Subject: Sending Apple events to the Finder.
  183. Date: 12 Jun 92 06:41:41 GMT
  184. Organization: Aiken Computation Lab, Harvard University
  185.  
  186. How can I send Apple events to the Finder itself, such as "Open
  187. Selection"? Inside Mac VI is not very clear about this. Normally
  188. for other applications I can determine the target address by using
  189. AECreateDesc and the application signature, then I can use the
  190. descriptor record in AECreateAppleEvent. But I'm confused about
  191. what to do when the target is the Finder.
  192.  
  193. Any help from AE gurus is very much appreciated.
  194.  
  195.  
  196. ===========================================================================
  197. Dr. Levent Mollamustafaoglu       Harvard University    
  198. molla@paone.harvard.edu    molla@metatron.harvard.edu
  199. ===========================================================================
  200.  
  201. +++++++++++++++++++++++++++
  202.  
  203. From: jackl@austin.apple.com (Jack Littleton)
  204. Date: 12 Jun 92 17:34:09 GMT
  205. Organization: Apple Computer, Inc.
  206.  
  207. In article <1992Jun12.064141.2357@das.harvard.edu>, molla@paone.uucp (Levent Mollamustafaoglu) writes:
  208. > How can I send Apple events to the Finder itself, such as "Open
  209. > Selection"? Inside Mac VI is not very clear about this. Normally
  210. > for other applications I can determine the target address by using
  211. > AECreateDesc and the application signature, then I can use the
  212. > descriptor record in AECreateAppleEvent. But I'm confused about
  213. > what to do when the target is the Finder.
  214.  
  215. There are several things you can do.  You can still use the finder's
  216. signature, or you can use the process manager's GetNextProcess routine to 
  217. loop through all processes until you find the Finder's process number, and 
  218. use that for the address descriptor.
  219.  
  220. How to loop through the open processes is shown in Inside Mac VI, page 29-11.
  221. Once you have the ProcessSerialNumber for the Finder, you don't need to do
  222. the loop anymore.  That is, unless the Finder quits and relaunches (for
  223. whatever reason), and thus gets a new ProcessSerialNumber.  If the Finder
  224. does get a new serial number, AESend will return -903, and that's your que
  225. to look for a new ProcessSerialNumber (do the loop thing again).
  226.  
  227. - --
  228. Jack Littleton
  229. Developer Tools Engineering Group
  230. Apple Computer, Inc.
  231.  
  232. +++++++++++++++++++++++++++
  233.  
  234. From: prw@Apple.COM (Paul Wenker)
  235. Date: 26 Jun 92 17:50:16 GMT
  236. Organization: Apple Computer Inc., Cupertino, CA
  237.  
  238. In article <27238@goofy.Apple.COM> jpugh@apple.com (Jon Pugh) writes:
  239. >In article <1992Jun12.064141.2357@das.harvard.edu>, molla@paone.uucp (Levent Mollamustafaoglu) writes:
  240. >> 
  241. >> How can I send Apple events to the Finder itself, such as "Open
  242. >> Selection"? Inside Mac VI is not very clear about this. Normally
  243. >> for other applications I can determine the target address by using
  244. >> AECreateDesc and the application signature, then I can use the
  245. >> descriptor record in AECreateAppleEvent. But I'm confused about
  246. >> what to do when the target is the Finder.
  247. >
  248. >ThatUs the way to do it.
  249. >
  250. >    kFinderSignature            = 'MACS';
  251. >
  252. >    aSig := kFinderSignature;
  253. >    err := AECreateDesc(typeApplSignature, @aSig, 4, finderAddress);
  254. >
  255. >Jon
  256. >kAERegistrar
  257.  
  258.  
  259. Here are some things to keep in mind when sending events to the Finder.
  260.  
  261. 1) Be sure you can handle the case where the Finder isn't running.  There
  262. are cases now (and there will be more in the future) where the Finder gets 
  263. replaced by another shell program.
  264.  
  265. 2) If you want to send an event to the current shell program, as opposed
  266. to the Finder specifically, you can loop through the existing
  267. processes looking for a process of type 'FNDR' and then use the
  268. ProcessSerialNumber of that process as your destination address.
  269.  
  270. 3) If you send an event to the current shell program, be sure you handle
  271. cases where that program doesn't support some or all of the Finder's events.
  272.  
  273. 4) Also, be aware that the current shell program and the Finder may both
  274. be running (i.e. there are two processes of type 'FNDR' running).  It's
  275. unlikely that any replacement shell program could do everything that the
  276. Finder does, so there will probably be times when the user needs to run
  277. the Finder in addition to their shell program.
  278.  
  279.  
  280. - -Paul Wenker
  281. - -Apple Computer
  282.  
  283. +++++++++++++++++++++++++++
  284.  
  285. From: molla@paone.uucp (Levent Mollamustafaoglu)
  286. Date: 26 Jun 92 19:16:17 GMT
  287. Organization: Aiken Computation Lab, Harvard University
  288.  
  289. In article <69283@apple.Apple.COM> prw@Apple.COM (Paul Wenker) writes:
  290. >
  291. >Here are some things to keep in mind when sending events to the Finder.
  292. >
  293. >1) Be sure you can handle the case where the Finder isn't running.  There
  294. >are cases now (and there will be more in the future) where the Finder gets 
  295. >replaced by another shell program.
  296. >
  297.  
  298. Another case to consider is when there is no shell and no Finder running.
  299. (Just add the Quit command to the Finder, launch other applications, then
  300. quit from the Finder) It seems the best way is to send the event to the
  301. Finder and deal with errors when you can not get a result. Using the
  302. process manager is also a good idea, but I would prefer to rely on the
  303. events themselves, instead of the Process Manager, which might change.
  304.  
  305. Thanks for all the help.
  306.  
  307.  
  308. ===========================================================================
  309. Dr. Levent Mollamustafaoglu       Harvard University    
  310. molla@paone.harvard.edu    molla@metatron.harvard.edu
  311. ===========================================================================
  312.  
  313. ---------------------------
  314.  
  315. From: samuel@cyklop.nada.kth.se (Samuel Cederlund)
  316. Subject: Light-weight processes in a Mac program
  317. Date: 21 Jun 92 16:34:28 GMT
  318. Organization: Royal Institute of Technology, Stockholm, Sweden
  319.  
  320.  
  321.  
  322. I'm writing a package for light-weight processes on the mac. The code is pretty
  323. straightforward. Stacks are allocated off a global array, ie
  324.  
  325. unsigned char    stacks[0x4000];
  326.  
  327. I'm using MPW 3.2 and Macsbug in 7.0.
  328. Changing the stack pointer seems to break the system, however. I have managed to
  329. run the program as an MPW tool by changing to user mode in the debugger.
  330.  
  331. I understand changing the stack pointer into some heap-allocated block would
  332. cause an error like "stack has grown into heap" or something similar. But global
  333. variable space?
  334.   Now, if there be a compelling reason why the SP must be in the stack area, then
  335. a solution would be simply to *grow* the stack area. Can this be done?
  336.  
  337.  
  338. I'd gratefully appreciate any comments on the above from anybody with greater
  339. insights than myself (5 000 000 000, although I hope not all of them read this
  340. newsgroup :-)).
  341.  
  342.     Sam
  343.  
  344. Samuel Cederlund        | "When a true genius appears in the world,
  345. programming Mac         |  it is the sign that the dunces are all in
  346. samuel@nada.kth.se        |  confederacy against him."
  347.  
  348. +++++++++++++++++++++++++++
  349.  
  350. From: hammett@sbsu1.aukuni.ac.nz (Tim Hammett)
  351. Date: 21 Jun 92 21:46:47 GMT
  352. Organization: University of Auckland, New Zealand.
  353.  
  354. samuel@cyklop.nada.kth.se (Samuel Cederlund) writes:
  355. >I'm writing a package for light-weight processes on the mac. The code is pretty
  356. >straightforward. Stacks are allocated off a global array, ie
  357.  
  358. >unsigned char    stacks[0x4000];
  359.  
  360. >I'm using MPW 3.2 and Macsbug in 7.0.
  361. >Changing the stack pointer seems to break the system, however. I have managed t
  362. >run the program as an MPW tool by changing to user mode in the debugger.
  363.  
  364. There are two problems with implementing threading by changing your stack
  365. pointer. First, as you have mentioned, if you put your stacks in the
  366. heap, a "stack has collided with heap" system error will probably
  367. occur. Second, some Toolbox/OS/System (not sure which) routines treat
  368. the space between A7 & the top of the heap as scratch space. This eliminates
  369. the avenue of allocating your threads' stacks on the stack.
  370.  
  371. This leaves the option of implementing your threading routines by
  372. stack copying. A package which does this (although source is not
  373. available) can be found in Apple's develop magazine, issue 6 (with additional
  374. info in issue 7), and on the developer CD's. There is also some (non-Mac
  375. specific information on threading in the AT&T C++ documentation that comes
  376. with MPW C++.
  377.  
  378. - --
  379. Tim Hammett, Botany Dept, Auckland University, New Zealand.
  380. t.hammett@aukuni.ac.nz   Phone: +64-9-373-7599 x8365    FAX: +64-9-373-7416
  381.  
  382. ---------------------------
  383.  
  384. From: slchambe@athena.mit.edu (Stephen L Chamberlin)
  385. Subject: need help writing a screensaver
  386. Date: 21 Jun 92 20:37:51 GMT
  387. Organization: Massachusetts Institute of Technology
  388.  
  389. I'm just getting started trying to write a simple screensaver which runs as a 
  390. background application with System 7, and I'm having trouble figuring out how
  391. to black out the screen. There doesn't seem to be any obvious way of turning
  392. the whole screen black from a background app. The only solutions I've come up
  393. with so far are:
  394.  
  395. 1. Create a new GrafPort the size of the main screen and paint it black. This
  396. doesn't work very well because the finder still redraws the icons for mounted
  397. drives on top of my nice new GrafPort, and certain other things like flashing
  398. cursors seem to poke through as well.
  399.  
  400. 2. Create a new, borderless window the size of the screen and paint it black.
  401. This works great as long as my screensaver app is the current app, but if it's
  402. in the background, the black window appears BEHIND the windows of the current 
  403. app, which makes it pretty useless as a screensaver. Calls to SelectWindow() 
  404. and BringToFront() don't seem to work. Apparently something prevents an 
  405. application running in the background from making one of its windows the
  406. front window.
  407.  
  408. Any great ideas? I'm wondering how screensavers such as After Dark black out
  409. the screen. Any ideas or input on this topic would be appreciated. Thanks!
  410.  
  411. Steve Chamberlin - slchambe@athena.mit.edu
  412.  
  413. +++++++++++++++++++++++++++
  414.  
  415. From: bi341@cleveland.Freenet.Edu (Steve G. Crutchfield)
  416. Organization: Case Western Reserve University, Cleveland, Ohio, (USA)
  417. Date: Mon, 22 Jun 92 05:42:29 GMT
  418.  
  419.  
  420. The first method you mentioned is, I think, the best way to go
  421. about it.  You can prevent other applications from drawing over
  422. your port by setting the global variable grayRgn to an empty
  423. region (of course you have to save it so you can restore it
  424. later).  Then, use the obscure Window Manager routine
  425. CalcVisBehind, passing it a pointer to the frontmost window,
  426. and the OLD grayRgn.  This makes sure the window manager knows
  427. that no drawing can take place in any windows.
  428.  
  429. You can also prevent things like SuperClock from appearing by
  430. setting the global variable mBarHeight to 0.  (You have to
  431. reset this one too, of course!)
  432.  
  433. Hope this helps.
  434.  
  435. Steve Crutchfield
  436. stevec@imsa.edu
  437.  
  438.  
  439. ---------------------------
  440.  
  441. From: Josh.Adams@bbs.oit.unc.edu (Josh Adams)
  442. Subject: Offscreen PixMaps
  443. Date: 12 Jun 92 12:31:16 GMT
  444. Organization: Extended Bulletin Board Service
  445.  
  446. What is the easiest way to have offscreen PixMaps? (yes, I thought awhile
  447. ago  when I was asking about type-casting PixMaps that I was doing it,
  448. but I was wrong...)  Anyway, I've heard something about gWorlds, but have
  449. not seen anything about them. I don't think they're in IM V, but they are in
  450. VI, which I don't have. If someone could tell me how to do offscreen PixMaps
  451. easily, I'd be very grateful...
  452.  
  453. Thanks...
  454. Josh
  455.  
  456. - --
  457.    The opinions expressed are not necessarily those of the University of
  458.      North Carolina at Chapel Hill, the Campus Office for Information
  459.         Technology, or the Experimental Bulletin Board Service.
  460.            internet:  bbs.oit.unc.edu or 152.2.22.80
  461.  
  462. +++++++++++++++++++++++++++
  463.  
  464. From: zobkiw@world.std.com (Joe Zobkiw)
  465. Date: 12 Jun 92 12:45:11 GMT
  466. Organization: The World Public Access UNIX, Brookline, MA
  467.  
  468. To learn about offscreen pixmaps or bitmaps, read the technical note about
  469. them. I forget the number off the top of my head but 120 seems to stick
  470. in my mind. There are two notes, one on bitmaps, one of pixmaps. The code
  471. included in the notes is ALL YOU NEED to make it work.
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478. - -- 
  479. - -- joe zobkiw                      Internet: zobkiw@world.std.com
  480. - --                                      AOL: AFL Zobkiw  
  481. - -- mac.synthesis.MIDI.THINK C.OOP.asm   CI$: 70712,515 
  482. - -- communications.networks.cool tunes...
  483.  
  484. +++++++++++++++++++++++++++
  485.  
  486. From: vvann@umbio.med.miami.edu (Vince Vann)
  487. Organization: University of Miami Medical School
  488. Date: Fri, 12 Jun 1992 18:22:02 GMT
  489.  
  490. Josh.Adams@bbs.oit.unc.edu (Josh Adams) writes:
  491. : What is the easiest way to have offscreen PixMaps? (yes, I thought awhile
  492. : ago  when I was asking about type-casting PixMaps that I was doing it,
  493. : but I was wrong...)  Anyway, I've heard something about gWorlds, but have
  494. : not seen anything about them. I don't think they're in IM V, but they are in
  495. : VI, which I don't have. If someone could tell me how to do offscreen PixMaps
  496. : easily, I'd be very grateful...
  497.  
  498. First, you should read the macintosh technical note #120 entitled
  499. "Principia Offscreen Graphics Environments".  This covers everything you
  500. need to know about PixMaps, CGrafPorts, and GDevices, plus some info on
  501. 32-Bit QuickDraw GWorlds.  
  502.  
  503. Second, if you are using THINK C 5.02 and TCL, I have written two TCL 
  504. classes that handle everything needed to setup an offscreen color graphics
  505. environment.  If you are interested in these classes (CPixelWorld and
  506. CPixelWorldPane), please contact me via E-mail and I will send you the
  507. source.  
  508.  
  509. Note: I am currently revising the PixelWorld classes. As soon as I complete
  510. the revisions, I will submit the source to the <ftp.brown.edu> archive.
  511. I'll post a message to C.S.M.P as soon as they are available.  
  512.  
  513. Good luck, 
  514. Vince
  515.  
  516. - --
  517. Vincent R. Vann
  518. University of Miami
  519. School of Medicine
  520. Miami, FL
  521.  
  522. E-mail:  vvann@umbio.med.miami.edu
  523.  
  524. +++++++++++++++++++++++++++
  525.  
  526. From: gluttony@reed.edu!gluttony.reed.edu!pcalahan (Patrick John Calahan)
  527. Date: 16 Jun 92 19:56:17 GMT
  528. Organization: Reed College, Portland, OR
  529.  
  530.  
  531. I want to do drawings in offscreen pixmaps.  I set everything up
  532. with NewPixMap(), and for the most part it works ok.
  533. BUT
  534.  
  535. If I copybits to the pixmap and then to the screen, all non-white pixels  
  536. are drawn on the screen in black.  However, If I copybits the image  
  537. directly to the screen, it looks fine.  This suggests to me that I am  
  538. setting one of the pixmap's fields incorrectly. (?)
  539.  
  540. Can anyone send me some code which shows how to do this correctly?
  541. Mail to pcalahan@reed.edu or post here...
  542.  
  543. Thanx in advance,
  544.     Pat
  545.  
  546. +++++++++++++++++++++++++++
  547.  
  548. From: Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz)
  549. Date: 24 Jun 92 05:23:45 GMT
  550. Organization: Dartmouth College, Hanover, NH
  551.  
  552. In article <m0lxjdU-0006ChC@gluttony.reed.edu>
  553. gluttony@reed.edu!gluttony.reed.edu!pcalahan (Patrick John Calahan)
  554. writes:
  555.  
  556. > If I copybits to the pixmap and then to the screen, all non-white pixels  
  557. > are drawn on the screen in black.  However, If I copybits the image  
  558. > directly to the screen, it looks fine.  This suggests to me that I am  
  559. > setting one of the pixmap's fields incorrectly. (?)
  560.  
  561. You could be setting thr "mode" field incorrectly, probably one of the
  562. "or" methods (srcOr (1) or notSrcOr (5)). For a standard copy, the
  563. transfer method is srcCopy (0).
  564.  
  565. Hope this helps,
  566. Jeremiah
  567.      _______________________________.
  568.     /___  . _____. ___  __  ___  . /
  569.        / / /____/ /__/ / / /__) / /
  570. __    / / _____/   ___/ / ___  / /
  571. \ \__/ / /____/ /\ \   / /__) / /___
  572.  \____/______/ /  \_\ /______/_____/
  573. jerbl@dartmouth.edu
  574.  
  575. "When the world is running down, you make the best of what's still
  576. around."
  577.                          -Sting
  578.  
  579. ---------------------------
  580.  
  581. From: jrk@information-systems.east-anglia.ac.uk (Richard Kennaway)
  582. Subject: Apple Event problem
  583. Date: 12 Jun 92 22:00:25 GMT
  584.  
  585. I recently upgraded an application to use Apple Events.  Just the required
  586. set, i.e. open appl, open doc, print doc, and quit.  I'm not very happy
  587. with the result.
  588.  
  589. It's a text editor.  Suppose I open it by double-clicking on a document it
  590. created, and then search for a string in that document.  So I go, without
  591. a pause, click-click, command-F (to bring up its search dialog), type
  592. string, return.  Previously, this would work.  It would open the doc via
  593. GetAppFiles, then start processing events and find my keystrokes waiting
  594. for it.  With Apple Events, however, I find that WaitNextEvent delivers my
  595. keystrokes before the Apple Event telling it to open a document.  This is
  596. not good - I want to search for the string after the document is open.  I
  597. have to wait until the window appears before I can do anything, and for no
  598. good reason.  (BTW, contrary to the example program and recommendations
  599. way back in IM vol.1, I never call FlushEvents at startup, and for the
  600. same reason.  It imposes an unnecessary wait on the user.  And besides,
  601. dammit, when I type, the machine should listen!)
  602.  
  603. I tried giving AppleEvents priority, by doing a WaitNextEvent(
  604. highLevelMask, ... ) and only if that returned false doing WaitNextEvent(
  605. everyEvent, ... ).  It solved the problem but created worse ones.  I got
  606. various unpleasant weirdness: losing some osEvts, behaving as if
  607. getFrontClicks was on, which it wasn't, etc., 
  608.  
  609. Since it currently has no use for any other Apple Events, I could just set
  610. it back to non-Sys7-aware, but I may want to do more exotic things with
  611. Apple Events in future.
  612.  
  613. Is there a solution?
  614.  
  615. BTW, what is the purpose of the "open application" Apple Event?  Informing
  616. an application that it is open seems remarkably superfluous.  Cogito ergo
  617. sum - if the app is in a position to wonder if it's running, it is.
  618.  
  619. - --
  620. Richard Kennaway     SYS, University of East Anglia, Norwich NR4 7TJ, U.K.
  621. Internet:  jrk@sys.uea.ac.uk               uucp:  ...mcsun!ukc!uea-sys!jrk
  622.  
  623. +++++++++++++++++++++++++++
  624.  
  625. From: jackl@austin.apple.com (Jack Littleton)
  626. Date: Sat, 13 Jun 1992 18:09:17 GMT
  627. Organization: Apple Computer, Inc.
  628.  
  629. In article <9705.9206122200@s4.sys.uea.ac.uk>, jrk@information-systems.east-anglia.ac.uk (Richard Kennaway) writes:
  630. > BTW, what is the purpose of the "open application" Apple Event?  Informing
  631. > an application that it is open seems remarkably superfluous.  Cogito ergo
  632. > sum - if the app is in a position to wonder if it's running, it is.
  633.  
  634. I know this isn't the answer you were looking for (i.e. how to handle events
  635. after immediately opening your document -- sounds tough), but anyway...
  636.  
  637. Only the Finder uses the open application event, and it is indeed sent after
  638. the application has been opened.  What it is supplied for is for
  639. initialization code such as bringing up a empty, untitled window.  It's
  640. simply a signal that your application was opened by the Finder.
  641.  
  642. - --
  643. Jack Littleton
  644. Developer Tools Engineering Group
  645. Apple Computer, Inc.
  646.  
  647.  
  648. +++++++++++++++++++++++++++
  649.  
  650. From: greeny@top.cis.syr.edu (J. S. Greenfield)
  651. Date: 13 Jun 92 21:17:45 GMT
  652. Organization: Syracuse University, CIS Dept.
  653.  
  654. In article <9705.9206122200@s4.sys.uea.ac.uk> jrk@information-systems.east-anglia.ac.uk (Richard Kennaway) writes:
  655. >I recently upgraded an application to use Apple Events.  Just the required
  656. >set, i.e. open appl, open doc, print doc, and quit.  I'm not very happy
  657. >with the result.
  658.  
  659. [...]
  660.  
  661. >I tried giving AppleEvents priority, by doing a WaitNextEvent(
  662. >highLevelMask, ... ) and only if that returned false doing WaitNextEvent(
  663. >everyEvent, ... ).  It solved the problem but created worse ones.  I got
  664. >various unpleasant weirdness: losing some osEvts, behaving as if
  665. >getFrontClicks was on, which it wasn't, etc., 
  666.  
  667. [...]
  668.  
  669. >Is there a solution?
  670. >
  671. >BTW, what is the purpose of the "open application" Apple Event?  Informing
  672. >an application that it is open seems remarkably superfluous.  Cogito ergo
  673. >sum - if the app is in a position to wonder if it's running, it is.
  674.  
  675. I'd say it's there for a very good reason--and it is very much related to
  676. the solution to your problem.  Because of the "open application" event,
  677. you know that no materr *how* your (apple-event aware) application is started,
  678. you will *always* receive an initial apple event after startup (either an
  679. 'oapp', an 'odoc', or a 'pdoc' event).
  680.  
  681. Because of this, you can program your application to await *only* high-level
  682. events *until* the initial apple event arrives.  (You shouldn't stop looking
  683. for apple events just because the first call to WaitNextEvent with the
  684. high-level event mask comes up with a null event.)
  685.  
  686. So set your program to wait for the initial apple event, process it, and then
  687. process any other events that are waiting.  That should make things work the
  688. way you want.
  689.  
  690.  
  691. - -- 
  692. J. S. Greenfield                                         greeny@top.cis.syr.edu
  693. (I like to put 'greeny' here, 
  694. but my d*mn system wants a 
  695. *real* name!)                        "What's the difference between an orange?"
  696.  
  697. +++++++++++++++++++++++++++
  698.  
  699. From: grobbins@Apple.COM (Grobbins)
  700. Date: 14 Jun 92 09:38:57 GMT
  701. Organization: DTS, more or less
  702.  
  703. In article <1992Jun13.171745.18868@newstand.syr.edu> greeny@top.cis.syr.edu writes:
  704. >Because of the "open application" event,
  705. >you know that no materr *how* your (apple-event aware) application is started,
  706. >you will *always* receive an initial apple event after startup (either an
  707. >'oapp', an 'odoc', or a 'pdoc' event).
  708.  
  709. While this is presently true under normal circumstances, application
  710. code should still be written defensively: do not demand an Apple
  711. event after starting up, and do not depend on receiving one of those three.
  712.  
  713. >Because of this, you can program your application to await *only* high-level
  714. >events *until* the initial apple event arrives.  (You shouldn't stop looking
  715. >for apple events just because the first call to WaitNextEvent with the
  716. >high-level event mask comes up with a null event.)
  717. >
  718. >So set your program to wait for the initial apple event, process it, and then
  719. >process any other events that are waiting.  That should make things work the
  720. >way you want.
  721.  
  722. It is not a good idea to mask out everything.  Always handle update
  723. events when they come in, and do remember that OS events are not
  724. queued, so if you are keeping track of being in the foreground or
  725. background by looking at suspend/resume events, then OS events should
  726. never be masked out.
  727.  
  728. There is a way to "prefetch" Apple events via the GetSpecificHighLevelEvent
  729. call, but it's rather ugly and probably best avoided.  See the Event Manager
  730. chapter of Inside Mac VI for documentation on this stuff.
  731.  
  732. Grobbins          grobbins@apple.com
  733.  
  734. Usual disclaimers apply.
  735.  
  736.  
  737. +++++++++++++++++++++++++++
  738.  
  739. From: jpugh@apple.com (Jon Pugh)
  740. Date: 15 Jun 92 05:44:59 GMT
  741. Organization: Apple Computer, Inc.
  742.  
  743. In article <1992Jun13.180917.12101@pcnntp.apple.com>, jackl@austin.apple.com (Jack Littleton) writes:
  744. > In article <9705.9206122200@s4.sys.uea.ac.uk>, jrk@information-systems.east-anglia.ac.uk (Richard Kennaway) writes:
  745. > > BTW, what is the purpose of the "open application" Apple Event?  Informing
  746. > > an application that it is open seems remarkably superfluous.  Cogito ergo
  747. > > sum - if the app is in a position to wonder if it's running, it is.
  748. > I know this isn't the answer you were looking for (i.e. how to handle events
  749. > after immediately opening your document -- sounds tough), but anyway...
  750. > Only the Finder uses the open application event, and it is indeed sent after
  751. > the application has been opened.  What it is supplied for is for
  752. > initialization code such as bringing up a empty, untitled window.  It's
  753. > simply a signal that your application was opened by the Finder.
  754.  
  755. I would like to add that if you launch and don't get an Open Application
  756. event, you should just go straight to your event loop without any fuss.
  757. This may be done to get you to launch in the background, like a daemon for
  758. example. This way you won't bother the user of the machine, who won't be
  759. looking for you, since you would've gotten an oapp, odoc or pdoc if he was
  760. looking at your program.
  761.  
  762. Once again, no oapp, no new doc. Just go to the main event loop after 
  763. initializing everything. You should be ready to do a new doc or whatever.
  764.  
  765. Jon Pugh
  766. kAERegistrar
  767.  
  768. +++++++++++++++++++++++++++
  769.  
  770. From: brady@cs.tcd.ie (Brady Michael)
  771. Organization: Trinity College, Dublin (Computer Science)
  772. Date: Mon, 15 Jun 1992 09:43:25 GMT
  773.  
  774. In article <68674@apple.Apple.COM> grobbins@Apple.COM (Grobbins) writes:
  775. >
  776. >While this is presently true under normal circumstances, application
  777. >code should still be written defensively: do not demand an Apple
  778. >event after starting up, and do not depend on receiving one of those three.
  779.  
  780. I'm looking for a little clarification on this:
  781. The way I have set up my application - Open Prolog - is this: after it starts up
  782. it looks for a pending high-level event, of type OAPP, ODOC or PDOC. If
  783. none of these are present, somewhere in the event queue, then the
  784. application presumes that it has been started in a non-HLE environment
  785. and goes on to getAppFiles, etc.
  786. Are you saying this is inadvisable?
  787.  
  788. Mike
  789. - -- 
  790. Michael Brady                         brady@cs.tcd.ie
  791. Department of Computer Science
  792. University of Dublin, Trinity College Dublin, Ireland
  793.  
  794.  
  795. +++++++++++++++++++++++++++
  796.  
  797. From: sstorkel@waimea.oracle.com (Scott Storkel)
  798. Organization: Oracle Corporation, Belmont, CA
  799. Date: Mon, 15 Jun 1992 18:12:47 GMT
  800.  
  801.  
  802. In article <1992Jun15.094325.6324@cs.tcd.ie> brady@cs.tcd.ie (Brady Michael) writes:
  803.  
  804. >I'm looking for a little clarification on this:
  805. >The way I have set up my application - Open Prolog - is this: after it starts up
  806. >it looks for a pending high-level event, of type OAPP, ODOC or PDOC. If
  807. >none of these are present, somewhere in the event queue, then the
  808. >application presumes that it has been started in a non-HLE environment
  809. >and goes on to getAppFiles, etc.
  810. >Are you saying this is inadvisable?
  811.  
  812. Okay, here's what I'd do. I think this is correct, but somebody from Apple
  813. can point me down the right path if I've strayed...
  814.  
  815. 1. Initialize everything. This includes all of the Toolbox managers as well
  816.    as application initialization code.
  817.  
  818. 2. Call Gestalt and see if the Apple Event Manager is present. If yes, goto 4.
  819.  
  820. 3. AE Manager isn't available, so open/print files using CountAppFiles(),
  821.    GetAppFiles(), etc. Create an "untitled" document if you would normally
  822.    do so in response to an oapp Apple Event.
  823.  
  824. 4. Enter your main event loop! Be sure to handle the oapp, odoc, and pdoc
  825.    Apple Events. If you get odoc or pdoc events, open or print the
  826.    corresponding files. If you get an oapp event, open an "untitled" document
  827.    or perform any other user visible actions that should happen when your
  828.    program is launched.
  829.  
  830. It's important to note that #4 should be your real, live, handle-everything
  831. main event-loop. Any questions?
  832.  
  833.  
  834.                                 -- Scott
  835.  
  836.  
  837. ==============================================================================
  838. Code Warrior                    500 Oracle Parkway
  839. Advanced Products Division            Box 659405
  840. Oracle Corporation                Redwood Shores, CA. 94065
  841. 415-506-2493                    FAX: 415-506-7216
  842. ==============================================================================
  843. - --
  844.  
  845. ==============================================================================
  846. Code Warrior                    500 Oracle Parkway
  847. Advanced Products Division            Box 659405
  848. Oracle Corporation                Redwood Shores, CA. 94065
  849. 415-506-2493                    FAX: 415-506-7216
  850. ==============================================================================
  851.  
  852. +++++++++++++++++++++++++++
  853.  
  854. From: baugh@voyager.east.isx.com (Earl Baugh)
  855. Date: 16 Jun 92 20:34:38 GMT
  856. Organization: ISX Corporation, East Coast Office
  857.  
  858. In article <1992Jun13.180917.12101@pcnntp.apple.com> jackl@austin.apple.com (Jack Littleton) writes:
  859. >In article <9705.9206122200@s4.sys.uea.ac.uk>, jrk@information-systems.east-anglia.ac.uk (Richard Kennaway) writes:
  860. >> BTW, what is the purpose of the "open application" Apple Event?  Informing
  861. >> an application that it is open seems remarkably superfluous.  Cogito ergo
  862. >> sum - if the app is in a position to wonder if it's running, it is.
  863. >
  864. >Only the Finder uses the open application event, and it is indeed sent after
  865. >the application has been opened.  
  866.  
  867.     Sorry to say, that's not the only way an application gets an Open
  868. Application Event.  Any application that uses LaunchApplication to launch
  869. your application can cause it to get an Open Application event.   (We
  870. won't discuss how badly the LaunchApplication call is documented.....)
  871. BTW, your application can get just about any event from the Launching program,
  872. open document comes to mind...
  873.  
  874. 'later
  875.  
  876. - -- 
  877.     Earl D. Baugh Jr.
  878.     ISX Corporation 
  879.     Internet : baugh@voyager.east.isx.com
  880.  
  881. +++++++++++++++++++++++++++
  882.  
  883. From: jpugh@apple.com (Jon Pugh)
  884. Date: 26 Jun 92 04:35:46 GMT
  885. Organization: Apple Computer, Inc.
  886.  
  887. In article <1992Jun15.094325.6324@cs.tcd.ie>, brady@cs.tcd.ie (Brady Michael) writes:
  888. > The way I have set up my application - Open Prolog - is this: after it starts up
  889. > it looks for a pending high-level event, of type OAPP, ODOC or PDOC. If
  890. > none of these are present, somewhere in the event queue, then the
  891. > application presumes that it has been started in a non-HLE environment
  892. > and goes on to getAppFiles, etc.
  893. > Are you saying this is inadvisable?
  894.  
  895. Yes, this is inadvisable.
  896.  
  897. Call Gestalt and see if the AE manager is available.  If you have the SIZE
  898. resource's highLevelEventAware bit then you will get an AE and you can just
  899. relax, initialize and idle, dealing with whatever you get or don't get when
  900. you do or don't get it, as you should.
  901.  
  902. If the AEM is not available, check the appFiles.
  903.  
  904. Jon
  905. kAERegistrar
  906.  
  907.  
  908. ---------------------------
  909.  
  910. From: jstevens@crick.ssctr.bcm.tmc.edu (Jason Philip Stevens)
  911. Subject: Getting the text from a TERec
  912. Date: 15 Jun 1992 17:46:56 GMT
  913. Organization: Baylor College of Medicine, Houston, Tx
  914.  
  915.  
  916. I'm trying to extract the text from a TERec into a standard C-style
  917. char* .  Suppose I have a TERec**, TEHandle.
  918.  
  919. Accoring to IM-1, p377, the hText member is a "handle to the text to
  920. be edited."  if I try *(*TEHandle)->hText, I get garbage.  If I try to
  921. use the TEGetText routine, I get a CharsHandle returned (a handle to a
  922. packed array of chars).  If I dereference that, I also get garbage.
  923. How do I actually get my hands on a char*?
  924.  
  925. BTW, I've tried using PtoCstr, on the assumption that the resultant string
  926. would be in Pascal format, and while it compiles, in use it generates a 
  927. bus error...
  928.  
  929. Thanks for any help...
  930.  
  931. - -jps
  932. - -- 
  933. Jason Stevens            Internet:  jstevens@bcm.tmc.edu
  934. Network User Services        Voice:  (713) 798-7370
  935. Baylor College of Medicine    Opinions expressed are mine alone.
  936.  
  937.  
  938. +++++++++++++++++++++++++++
  939.  
  940. From: zobkiw@world.std.com (Joe Zobkiw)
  941. Organization: The World Public Access UNIX, Brookline, MA
  942. Date: Tue, 16 Jun 1992 01:03:28 GMT
  943.  
  944. In article <12523@gazette.bcm.tmc.edu> jstevens@crick.ssctr.bcm.tmc.edu (Jason Philip Stevens) writes:
  945. >
  946. >I'm trying to extract the text from a TERec into a standard C-style
  947. >char* .  Suppose I have a TERec**, TEHandle.
  948. >
  949.  
  950. Well, first of all, if your TERec contains more than 255 characters of text
  951. you may bomb when you try to cast it as a Str255. However, if you want to do
  952. this you can use something like:
  953.  
  954. void TE2Str(TEHandle te, Str255 str)
  955. {
  956.     GetIText((te)->hText, str);
  957. }
  958.  
  959. void Str2TE(Str255 str, TEHandle te)
  960. {
  961.     TESetText((Ptr)&str[1], (long)str[0], te);
  962. }
  963.  
  964. This might also help you with your other problem, finding the text. 
  965. Remember, hText is a _Handle_ to the text in question. Two dereferences
  966. of a Handle get you to it's data.
  967.  
  968.  
  969. - -- 
  970. - -- joe zobkiw                      Internet: zobkiw@world.std.com
  971. - --                                      AOL: AFL Zobkiw  
  972. - -- mac.synthesis.MIDI.THINK C.OOP
  973. - -- asm.comm.networks.cool tunes...
  974.  
  975. +++++++++++++++++++++++++++
  976.  
  977. From: lari@bach.cs.unc.edu (Humayun Lari)
  978. Date: 16 Jun 92 18:12:33 GMT
  979. Organization: University of North Carolina, Chapel Hill
  980.  
  981. In article <Bpwyxu.1n6@world.std.com> zobkiw@world.std.com (Joe Zobkiw) writes:
  982. >In article <12523@gazette.bcm.tmc.edu> jstevens@crick.ssctr.bcm.tmc.edu (Jason Philip Stevens) writes:
  983. >>
  984. >>I'm trying to extract the text from a TERec into a standard C-style
  985. >>char* .  Suppose I have a TERec**, TEHandle.
  986. >>
  987. >
  988. >Well, first of all, if your TERec contains more than 255 characters of text
  989. >you may bomb when you try to cast it as a Str255. However, if you want to do
  990. >this you can use something like:
  991. >
  992. >void TE2Str(TEHandle te, Str255 str)
  993. >{
  994. >    GetIText((te)->hText, str);
  995. >}
  996.  
  997. Um, isn't GetIText only for dialogs? Perhaps this might be a bit better:
  998.  
  999. OSErr TE2CStr(TEHandle te, char *str)
  1000. {
  1001.     short  textLength;
  1002.  
  1003.     textLength = (**te).teLength;
  1004.     str = (char *)NewPtr(textLength + 1);
  1005.     if (MemError() != noErr)
  1006.         return MemError();
  1007.  
  1008.     BlockMove( (Ptr)(*TEGetText(te)), (Ptr)str, textLength);
  1009.     str[textLength] = '\0';
  1010.  
  1011.     return noErr;
  1012. }
  1013.  
  1014. Since you're using C, this should work OK no matter how much text the TERec
  1015. contains (up to the 32K limit). Anyone see a silly mistake? (My C's kind of
  1016. rusty.)
  1017.  
  1018. >
  1019. >void Str2TE(Str255 str, TEHandle te)
  1020. >{
  1021. >    TESetText((Ptr)&str[1], (long)str[0], te);
  1022. >}
  1023.  
  1024. void CStr2TE(char *str, TEHandle te)
  1025. {
  1026.     TESetText((Ptr)str, strlen(str), te);
  1027. }
  1028.  
  1029. >
  1030. >This might also help you with your other problem, finding the text. 
  1031. >Remember, hText is a _Handle_ to the text in question. Two dereferences
  1032. >of a Handle get you to it's data.
  1033.  
  1034. After years and years, I still forget... :-)
  1035.  
  1036.  
  1037. Humayun Lari
  1038. (lari@cs.unc.edu)
  1039.  
  1040. +++++++++++++++++++++++++++
  1041.  
  1042. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  1043. Date: 17 Jun 92 04:26:05 GMT
  1044. Organization: U.C. Berkeley Open Computing Facility
  1045.  
  1046. > >void TE2Str(TEHandle te, Str255 str) >{ > GetIText((te)->hText,
  1047. > str); >} 
  1048. > Um, isn't GetIText only for dialogs? Perhaps this might be a bit
  1049. > better:
  1050.  
  1051. I noticed the GetIText call as well, but thought about it and had to smile.
  1052.  
  1053. ":-)"
  1054.  
  1055. When you perform a GetDItem on an edit text in a dialog, you get a handle to
  1056. the text of the item.  GetIText just copies at most 255 bytes of this handle
  1057. into a pascal string.  So long as it is passed a handle to text, you're OK.
  1058.  
  1059. vrey nice.
  1060. - -Elizabeth
  1061.  
  1062. +++++++++++++++++++++++++++
  1063.  
  1064. From: zobkiw@world.std.com (Joe Zobkiw)
  1065. Date: 17 Jun 92 10:46:38 GMT
  1066. Organization: The World Public Access UNIX, Brookline, MA
  1067.  
  1068. The GetIText 'trick' came from THINK Reference. I will not take credit
  1069. for it. I just found it to be an easy to understand way of doing things :)
  1070.  
  1071.  
  1072. - -- 
  1073. - -- joe zobkiw                      Internet: zobkiw@world.std.com
  1074. - --                                      AOL: AFL Zobkiw  
  1075. - -- mac.synthesis.MIDI.THINK C.OOP
  1076. - -- asm.comm.networks.cool tunes...
  1077.  
  1078. +++++++++++++++++++++++++++
  1079.  
  1080. Date: 24 Jun 92 19:33:49 GMT
  1081. From: jopa@tkk.tele.fi (Jorma Paananen)
  1082.  
  1083. lari@bach.cs.unc.edu (Humayun Lari) writes:
  1084. > void CStr2TE(char *str, TEHandle te)
  1085. > {
  1086. >     TESetText((Ptr)str, strlen(str), te);
  1087. > }
  1088.  
  1089. >From IM I-383:
  1090.   "TESetText doesn't dispose of any text currently in the edit record"
  1091.  
  1092. What is the correct way to free old text ?
  1093.  
  1094. Jorma
  1095. jopa@tkk.tele.fi
  1096.  
  1097. +++++++++++++++++++++++++++
  1098.  
  1099. From: lari@bach.cs.unc.edu (Humayun Lari)
  1100. Date: 25 Jun 92 20:52:29 GMT
  1101. Organization: University of North Carolina, Chapel Hill
  1102.  
  1103. In article <jopa.709414429@tkk.tele.fi> jopa@tkk.tele.fi (Jorma Paananen) writes:
  1104. >lari@bach.cs.unc.edu (Humayun Lari) writes:
  1105. >> void CStr2TE(char *str, TEHandle te)
  1106. >> {
  1107. >>     TESetText((Ptr)str, strlen(str), te);
  1108. >> }
  1109. >
  1110. >From IM I-383:
  1111. >  "TESetText doesn't dispose of any text currently in the edit record"
  1112. >
  1113. >What is the correct way to free old text ?
  1114.  
  1115.  
  1116. Well, I *did* have a feeling that it couldn't be that simple :-).
  1117. Maybe this will work: (Anyone see more amazingly silly mistakes?)
  1118.  
  1119. void CStr2TE(char *str, TEHandle te)
  1120. {
  1121.      TESetSelect(0, 32767, te);   /* IM I-385 */
  1122.      TEDelete(te);                /* IM I-387 */
  1123.      TESetText((Ptr)str, strlen(str), te);
  1124. }
  1125.  
  1126. Note that the edit record should be inactive, or else the selection will be
  1127. highlighted. If the string is long, you might prefer to use TEGetText to access
  1128. the text handle directly, so you can check for memory errors when resizing the
  1129. handle to fit.
  1130.  
  1131. Humayun Lari
  1132. (lari@cs.unc.edu)
  1133. ObSig: "Technology changes rapidly; people and meaning do not." -- Kevin Bjorke
  1134.  
  1135. ---------------------------
  1136.  
  1137. End of C.S.M.P. Digest
  1138. **********************
  1139.